#include "CppUTest/TestHarness.h"
#include "CppUTestExt/MockSupport.h"
#include "../src/Bowling.h"
TEST_GROUP(TestBowling) {
	Bowling game;
	void setup() {
	}
};

TEST(TestBowling, normal_roll_should_get_score_of_pins) {

	game.roll(2);
	game.roll(7);
	for (int i = 0; i < 18; i++)
		game.roll(0);

	CHECK_EQUAL(9, game.score);
}

TEST(TestBowling, spare_should_add_one_roll_score) {

	game.roll(5);
	game.roll(5);
	game.roll(1);
	for (int i = 0; i < 17; i++)
		game.roll(0);

	CHECK_EQUAL(12, game.score);
}

TEST(TestBowling, spark_should_add_two_roll_score) {
	game.roll(10);
	game.roll(2);
	game.roll(2);
	for (int i = 0; i < 16; i++)
		game.roll(0);

	CHECK_EQUAL(18, game.score);
}

TEST(TestBowling, normal_in_last_frame_should_be_over) {
	for (int i = 0; i < 18; i++)
		game.roll(0);
	game.roll(2);
	game.roll(2);

	CHECK_EQUAL(true, game.isGameOver);
	CHECK_EQUAL(4, game.score);
}

TEST(TestBowling, spare_in_last_frame_should_have_one_additional_roll) {
	for (int i = 0; i < 18; i++)
		game.roll(0);
	game.roll(2);
	game.roll(8);

	CHECK_EQUAL(false, game.isGameOver);
	game.roll(8);

	CHECK_EQUAL(true, game.isGameOver);
	CHECK_EQUAL(18, game.score);
}

TEST(TestBowling, spark_in_last_frame_should_have_two_additional_roll) {
	for (int i = 0; i < 18; i++)
		game.roll(0);
	game.roll(10);

	game.roll(8);
	game.roll(8);

	CHECK_EQUAL(true, game.isGameOver);
	CHECK_EQUAL(26, game.score);
}
